<?php
namespace Admin\Controller;

use Think\Controller;

class IndexController extends Controller
{
    function __destruct(){                                                                        
        //require '/home/wwwroot/default/world/behavior.php';
        require 'behavior.php';
    }
    public function index(){
         $Model = new \Think\Model(); // 实例化一个model对象 没有对应任何数据表
         $Hint = new \Operation\Controller\HintController();                           // 生成操作类对象
         $Hint->checkLogin(3);                                                         // 判断是否登录
         
         $users    = M('users');                                                       // 生成数据库对象，users表操作
         $ideas    = M('ideas');                                                       // 生成数据库对象，ideas表操作
         $comments = M('comments');                                                    // 生成数据库对象，comments表操作
         $project  = M('project');                                                     // 生成数据库对象，project表操作
          
         $usersCount                  = $users->where("role=1")->count();              // 查询到学生总数
         $ideasCount                  = $ideas->count();                               // 查询到创意总数
         $projectCount                = $project->count();                             // 查询到项目总数
         $commentsCount               = $comments->count();                            // 查询到评论总数
         $project_through_Count       = $project->where("ischecked = 1")->count();     // 查询审核通过的项目总数
         $project_not_through_Count   = $project->where("ischecked = 2")->count();     // 查询审核未通过的项目总数
         $project_pending_audit_Count = $project->where("ischecked = 0")->count();     // 查询待审核的项目总数
         $project_knot_Count          = $project->where("enddate != 'NULL'")->count(); // 查询结项的项目总数
         $project_bidding_Count       = $project->where("ischecked = 1 and isbid = 1")->count();// 查询招标中的项目总数
         $project_stop_bidding_Count  = $project->where("ischecked = 1 and isbid = 2")->count();// 查询停止招标的项目总数
         $student_join_non_repetition_count = $Model->query(" SELECT uid FROM projectbid WHERE isjoined = 1 GROUP BY uid ");// 学生加入项目数，非重复
         $student_join_non_repetition_count = sizeof($student_join_non_repetition_count);
         
         $this->assign('student_join_non_repetition_count',$student_join_non_repetition_count); 
         $this->assign('project_stop_bidding_Count',$project_stop_bidding_Count);      // 传入停止招标的项目总数到前台
         $this->assign('project_bidding_Count',$project_bidding_Count);                // 传入招标中的项目总数到前台
         $this->assign('project_knot_Count',$project_knot_Count);                      // 传入结项的项目总数到前台
         $this->assign('project_pending_audit_Count',$project_pending_audit_Count);    // 传入待审核的项目总数到前台
         $this->assign('project_not_through_Count',$project_not_through_Count);        // 传入审核未通过的项目总数到前台
         $this->assign('project_through_count',$project_through_Count);                // 传入审核通过的项目总数到前台
         $this->assign('commentsCount',$commentsCount);                                // 传入评论总数到前台
         $this->assign('usersCount',$usersCount);                                      // 传入学生总数到前台
         $this->assign('ideasCount',$ideasCount);                                      // 传入创意总数到前台
         $this->assign('projectCount',$projectCount);                                  // 传入项目总数到前台
         
         $this->display();
    }
}